package controller;


import entity.School;
import entity.Student;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import service.StudentService;

import javax.annotation.Resource;

@Controller
@RequestMapping("/student")
public class StudentController {

    @Resource
    private StudentService service;

    @RequestMapping("/helloThymeleaf.do")
    public String thymeleaf(Model model) {
        model.addAttribute("helloThymeleaf","Hello Thymeleaf");
        return "hello";
    }

    @RequestMapping("/valExpress.do")
    public String queryStudent(Model model) {
        model.addAttribute("myName","张三");
        model.addAttribute("myAge","20");

//        添加对象类型
        Student student = new Student();
        student.setId(1001);
        student.setAge(15);
        student.setName("Thyme");

        School school = new School();
        school.setSchoolName("ZUEL");
        school.setSchoolAddress("WUHAN");
        student.setMySchool(school);

        model.addAttribute("student",student);
        return "var1";
    }

    @RequestMapping("/linkThy.do")
    public String doLink(Model model){
        model.addAttribute("queryStudent","/query/student");
        model.addAttribute("myName","HUEL");
        return "link";
    }

    @RequestMapping("/i18N.do")
    public String i18N(Model model){
        return "login";
    }

}
